require.config({
    baseUrl:"./",
    paths:{
        jq:"../libs/jquery",
        getGoods:"../modules/getGoods",
        indexRender:"../modules/indexRender",
        setLocal:"../modules/setLocal",
        pa:"../modules/jquery.pagination"
    }
})
require(["jq","getGoods","indexRender","setLocal","pa"],function(_,getGoods,render,setLocal,pagination){
    const url = "http://localhost:3000/api"
    const cont = $(".cartshow")
    const pa = $(".pagination")
    getGoods(url,res=>{
        res = JSON.parse(res).msg;
// 2.渲染页面
        render(res,cont)
})
// 3.绑定事件
cont.on("click",".add",function(){
    const id = $(this).parent().attr("index")
        // 获取当前商品的价格，存入本地存储，方便计算总价
    const price = $(this).prev().children( "div:last-child").find("p:last-child").children().html();
// 4.将点击商品信息存入本地存储
    setLocal(id,price)
})
// 3.绑定事件
cont.on("click","a",function(){
    const id = $(this).parent().attr("index")
// 4.将点击商品信息存入本地存储
    setLocal(id)
})
// pa.on("click","a",function(){

// })
})






